package com.spider.silence.job;

import com.spider.silence.downloader.Njd1Downloader;
import com.spider.silence.pool.Njd1DownloaderPool;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.StatefulJob;

import java.util.List;

/**
 * @author Administrator
 * @description 描述
 * @time 2017/4/17 0017
 */
public class Njd1Job implements StatefulJob {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        Njd1DownloaderPool pool = null;
        Njd1Downloader downloader = null;

        try{
            pool = Njd1DownloaderPool.getInstance();
            downloader = pool.fetchDownLoader(1000);
            List<String> urlList = downloader.getUrl();
            //生成任务队列
            downloader.generateTask(urlList);

        }catch(Exception e){
            e.printStackTrace();
        }finally {
            if(downloader != null){
                pool.releaseDownLoader(downloader);
            }
        }
    }
}
